/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Classes;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Jaroslav
 */
@Entity
@Table(name = "project_user")
@NamedQueries({@NamedQuery(name = "ProjectUser.findByProjectId", query = "SELECT p FROM ProjectUser p WHERE p.projectUserPK.projectId = :projectId"), @NamedQuery(name = "ProjectUser.findByUserId", query = "SELECT p FROM ProjectUser p WHERE p.projectUserPK.userId = :userId"), @NamedQuery(name = "ProjectUser.findByGroupId", query = "SELECT p FROM ProjectUser p WHERE p.projectUserPK.groupId = :groupId")})
public class ProjectUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ProjectUserPK projectUserPK;

    public ProjectUser() {
    }

    public ProjectUser(ProjectUserPK projectUserPK) {
        this.projectUserPK = projectUserPK;
    }

    public ProjectUser(int projectId, int userId, int groupId) {
        this.projectUserPK = new ProjectUserPK(projectId, userId, groupId);
    }

    public ProjectUserPK getProjectUserPK() {
        return projectUserPK;
    }

    public void setProjectUserPK(ProjectUserPK projectUserPK) {
        this.projectUserPK = projectUserPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (projectUserPK != null ? projectUserPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProjectUser)) {
            return false;
        }
        ProjectUser other = (ProjectUser) object;
        if ((this.projectUserPK == null && other.projectUserPK != null) || (this.projectUserPK != null && !this.projectUserPK.equals(other.projectUserPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Classes.ProjectUser[projectUserPK=" + projectUserPK + "]";
    }

}
